package com.tenbent.product.center.insures.dto;

import com.tenbent.product.base.dto.BaseDto;
import com.tenbent.product.center.insures.bo.Product;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * 产品DTO类
 *
 * @author Randy
 *
 *         Created by ThinkPad on 2017/8/21.
 */
public class ProductDto extends BaseDto {

	/** 产品编码 **/
	@NotEmpty(message = "{product.code.not.empty}")
	private String pdCode;

	/** 产品名称 **/
	@NotEmpty(message = "{product.name.not.empty}")
	private String pdName;

	/** 产品状态(1 启用 2 停用) **/
	private Integer status;

	/** 最小价格 **/
	@NotNull(message = "{product.min.amount.not.empty}")
	@Digits(integer = 18, fraction = 2, message = "{product.min.amount.illegal}")
	private BigDecimal minAmount;

	/** 产品图片地址 **/
	private String images;

	/** 产品分类ID **/
	@NotNull(message = "{product.category.id.not.empty}")
	private Integer categoryId;

	/** 产品分类名称 **/
	@NotEmpty(message = "{product.category.name.not.empty}")
	private String categoryName;

	/** 保险公司ID **/
	@NotNull(message = "{product.insurer.id.not.empty}")
	private Integer insurerId;

	/** 保险公司名称 **/
	@NotEmpty(message = "{product.insurer.name.not.empty}")
	private String insurerName;

	/** 出单类型(1 线上 2 线下) **/
	@NotNull(message = "{product.out.type.not.empty}")
	private Integer outType;

	/** 产品描述 **/
	@NotEmpty(message = "{product.desc.not.empty}")
	private String desc;

	/** 产品备注 **/
	private String remark;

	/** 产品扩展 **/
	private String extendInfo;

	// ===============以下为业务属性============================//
	/** 产品保障大类 */
	// @JsonInclude(JsonInclude.Include.NON_NULL)
	// 此处可以不用配置，因为配置了全局 mappingJackson2HttpMessageConverter
	private List<SafeguardCategoryTypeDto> safeguardCategoryTypes;

	/** 产品套餐 */
	// @JsonInclude(JsonInclude.Include.NON_NULL)
	private List<SafeguardPackageDto> safeguardPackages;

	/** sku信息 */
	// @JsonInclude(JsonInclude.Include.NON_NULL)
	private List<SkuInfoDto> skuInfos;

	public ProductDto() {
	}

	public ProductDto(Product product) {
		super(product);
		setPdCode(product.getPdCode());
		setPdName(product.getPdName());
		setStatus(product.getStatus());
		setMinAmount(product.getMinAmount());
		setImages(product.getImages());
		setCategoryId(product.getCategoryId());
		setCategoryName(product.getCategoryName());
		setInsurerId(product.getInsurerId());
		setInsurerName(product.getInsurerName());
		setOutType(product.getOutType());
		setDesc(product.getDesc());
		setRemark(product.getRemark());
		setExtendInfo(product.getExtendInfo());
	}

	public Product transToBo() {
		Product product = new Product();
		super.transToBo(product);
		product.setPdCode(this.pdCode);
		product.setPdName(this.pdName);
		product.setStatus(this.status);
		product.setMinAmount(this.minAmount);
		product.setImages(this.images);
		product.setCategoryId(this.categoryId);
		product.setCategoryName(this.categoryName);
		product.setInsurerId(this.insurerId);
		product.setInsurerName(this.insurerName);
		product.setOutType(this.outType);
		product.setDesc(this.desc);
		product.setRemark(this.remark);
		product.setExtendInfo(this.extendInfo);
		return product;
	}

	public String getPdCode() {
		return pdCode;
	}

	public void setPdCode(String pdCode) {
		this.pdCode = pdCode;
	}

	public String getPdName() {
		return pdName;
	}

	public void setPdName(String pdName) {
		this.pdName = pdName;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public BigDecimal getMinAmount() {
		return minAmount;
	}

	public void setMinAmount(BigDecimal minAmount) {
		this.minAmount = minAmount;
	}

	public String getImages() {
		return images;
	}

	public void setImages(String images) {
		this.images = images;
	}

	public Integer getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public Integer getInsurerId() {
		return insurerId;
	}

	public void setInsurerId(Integer insurerId) {
		this.insurerId = insurerId;
	}

	public String getInsurerName() {
		return insurerName;
	}

	public void setInsurerName(String insurerName) {
		this.insurerName = insurerName;
	}

	public Integer getOutType() {
		return outType;
	}

	public void setOutType(Integer outType) {
		this.outType = outType;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getExtendInfo() {
		return extendInfo;
	}

	public void setExtendInfo(String extendInfo) {
		this.extendInfo = extendInfo;
	}

	public List<SafeguardCategoryTypeDto> getSafeguardCategoryTypes() {
		return safeguardCategoryTypes;
	}

	public void setSafeguardCategoryTypes(List<SafeguardCategoryTypeDto> safeguardCategoryTypes) {
		this.safeguardCategoryTypes = safeguardCategoryTypes;
	}

	public List<SafeguardPackageDto> getSafeguardPackages() {
		return safeguardPackages;
	}

	public void setSafeguardPackages(List<SafeguardPackageDto> safeguardPackages) {
		this.safeguardPackages = safeguardPackages;
	}

	public List<SkuInfoDto> getSkuInfos() {
		return skuInfos;
	}

	public void setSkuInfos(List<SkuInfoDto> skuInfos) {
		this.skuInfos = skuInfos;
	}
}
